
package com.nanyang.tms.api.dto.request.receipt;

import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.nanyang.common.core.dict.CommonEnum;
import com.nanyang.common.core.domain.ApiRequest;
import com.nanyang.common.core.exception.ValidateException;
import com.nanyang.tms.common.dict.TmsCommonEnum;
import com.nanyang.tms.common.util.CheckUtils;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.ValidationException;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>Description:请求参数</p>
 * 
 * @author
 * @date 2020年11月11日 上午10:02:18
 * @Copyright Copyright (c) 2020 www.nanyang.cn Inc. All rights reserved.
 */
@Data
public class ReceiptBillAddRequest extends ApiRequest {
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;


	@JsonIgnore
	private String pin;

	/**
	 * 客户编码
	 */
	@NotEmpty(message = "客户编码不能为空")
	@Length(max = 32, message = "companyCode长度需小于32个字符")
	private String companyCode;

	/**
	 * 客户名称
	 */
	@NotEmpty(message = "客户名称不能为空")
	@Length(max = 50, message = "companyName长度需小于50字符")
	private String companyName;

	/**
	 * 收货时间
	 */
	@NotEmpty(message = "收货时间不能为空")
	@Length(max = 50, message = "receiptTime长度需小于50字符")
	private String receiptTime;

	/**
	 * 收货地点
	 */
	@NotEmpty(message = "收货地点不能为空")
	@Length(max = 100, message = "address长度需小于100字符")
	private String address;



	@Override
	public void requestCheck() {
		if (ObjectUtil.isNull(receiptTime)|| !CheckUtils.checkDateTime(receiptTime)) {
			throw new ValidateException(CommonEnum.ARG_NOTVALID.getCode(), "收货时间格式不正确！");
		}
	}

}
